package fun.tan90.device.main.listener;

import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.event.AppPrestopEndEvent;
import org.noear.solon.core.event.EventListener;
import org.noear.solon.hotplug.PluginManager;

@Slf4j
@Component
public class AppPrestopEndEventListener implements EventListener<AppPrestopEndEvent> {

    @Override
    public void onEvent(AppPrestopEndEvent event) throws Throwable {
        PluginManager.getPlugins().forEach(plugin -> {
            PluginManager.stop(plugin.getName());
            PluginManager.unload(plugin.getName());
        });
    }
}